
<style lang="less" scoped>
// 占位div样式
.left-div {
  visibility: hidden;
  border-style: solid;
  border-color: black;
  /* border-right-color: red; */
  border-color: transparent;
}
// 内容部分
.content-wrapper {
  margin: 0px 10px 0px 0px;

  // 表单按钮部分
  .content-request-button {
    height: 28px;
  }
}
</style>

<template>
  <div class="content-request">
    <!-- <Row>
      <Col span="3" class="left-div"></Col>
    <Col span="18">-->
    <div class="content-wrapper">
      <!-- 内容 -->
      <div>
        <Form ref="RequestForm" :model="reqeustForm" :label-width="50">
          <Row>
            <Col>
              <FormItem label="标题" prop="title">
                <Input v-model="reqeustForm.title" placeholder="请输入标题"></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col>
              <FormItem label="内容" prop="content" disabled>
                <edite-page :formObj="reqeustForm" :isReset="contentIsReset"></edite-page>
              </FormItem>
            </Col>
          </Row>
          <div class="content-request-button">
            <Button type="primary" style="float:right" @click="handleSubmit">提交</Button>
            <Button @click="handleReset" style="margin-right: 8px; float:right">重置</Button>
            <Button style="float:right; margin-right: 8px;" @click="handleCancel">取消</Button>
          </div>
        </Form>
      </div>
    </div>
    <!-- </Col>
      <Col span="3"></Col>
    </Row>-->
  </div>
</template>
<script>
import httpUtil from '@/libs/httpUtil'
import editePage from '@/view/components/editor/editor.vue'

export default {
  name: 'ComRoomRequest',
  components: {
    editePage
  },
  props: ['reqeustForm'],
  data () {
    return {
      // reqeustForm: {},
      contentIsReset: false, // 富文本编辑框是否重置
      professionList: [],
      courseList: [],
      selectProCourseList: [],
      professionCourseRelation: []
    }
  },
  methods: {
    handleSubmit () {
      // this.$refs[name].validate((valid) => {
      //     if (valid) {
      //         this.$Message.success('Success!');
      //     } else {
      //         this.$Message.error('Fail!');
      //     }
      // })
      this.$httpUtil.asyncPost('web/raroom/request/request', this.reqeustForm, res => {
        if (res.data.code === 200) {
          this.$Message.success(res.data.msg)
          this.handleReset()
          this.$emit('handle-success')
        } else {
          this.$Message.error(res.data.msg)
        }
      })
    },
    handleReset () {
      this.$refs['RequestForm'].resetFields()
      this.reqeustForm = {}
      this.contentIsReset = true
      this.selectProCourseList = this.courseList
      setTimeout(() => {
        // 解决第二次重置，富文本框中内容不消失
        this.contentIsReset = false
      }, 500)
    },

    // 取消提问
    handleCancel () {
      this.handleReset(), this.$emit('handle-cancel')
    },

    // 跳转的提问页面
    gotoIndex () {
      this.$router.push({ name: 'index' })
    }

  },
  mounted: function () {
  }
}
</script>
